package cn.wolfcode.luowowo.controller;

import cn.wolfcode.luowowo.domain.Destination;
import cn.wolfcode.luowowo.domain.Region;
import cn.wolfcode.luowowo.domain.Strategy;
import cn.wolfcode.luowowo.domain.StrategyCatalog;
import cn.wolfcode.luowowo.service.IDestinationService;
import cn.wolfcode.luowowo.service.IRegionService;
import cn.wolfcode.luowowo.service.IStrategyService;
import cn.wolfcode.luowowo.service.ITravelService;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationsController {
    //注入区域服务接口
    @Autowired
    private IRegionService regionService;
    //注入目的地服务接口
    @Autowired
    private IDestinationService destinationService;
    //注入攻略服务接口
    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;

    //查询热门区域
    @GetMapping("/hotRegion")
    public Object hotRegion() {
        List<Region> hotRegion = regionService.getHotRegion();
        return JsonResult.success(hotRegion);
    }

    //查找子目的地
    @GetMapping("/search")
    public Object search(String regionId) {
        List<Destination> list = destinationService.search(regionId);
        return JsonResult.success(list);
    }

    @GetMapping("/toasts")
    public Object toasts(String destId) {
        List<Destination> list = destinationService.getToasts(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/detail")
    public Object detail(String id) {
        return JsonResult.success(destinationService.get(id));
    }

    //概况目录分类
    @GetMapping("/catalogs")
    public Object catalogs(String destId) {
        List<StrategyCatalog> list = destinationService.catalogs(destId);
        return JsonResult.success(list);
    }

    //查询目的地下攻略点击量前3的攻略
    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){
        List<Strategy> viewnumTop3 = strategyService.getViewnumTop3(destId);
        return JsonResult.success(viewnumTop3);
    }


    //查询目的地下游记点击量前3的攻略
    @GetMapping("/travels/viewnumTop3")
    public Object travelsTop3(String destId){
         ;
        return JsonResult.success(travelService.getViewnumTop3(destId));
    }
}
